<html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">
dt {
  font-style: italic;
  margin-top: 15px;
  margin-bottom: 3px;
  margin-left: 0px;
  border-bottom: 1px dotted black;
}
dd {
  margin-left: 10px;
}
table {
  border-collapse:collapse;
  border: 1px solid black;
  margin-top: 7px;
}
th {
  border: 1px solid black;
  padding: 3 7 3 7;
}
td {
  border: 1px solid black;
  padding: 3 7 3 7;
}
</style></head><body><p><a name="dup"></a><b>dup</b> :
  duplicate top single-word item on the stack : <a href="opcodes.html">index</a> : <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitInsn(int)">visitInsn()</a></p><dl><dt>Description</dt><dd>This pops the top single-word value off the operand stack, and then
pushes that value twice - i.e. it makes an extra copy of the top item on the
stack.<br></br>This instruction cannot be used to duplicate two-word items (longs or doubles)
- use dup2 instead.</dd><dt>Example</dt><dd><pre>
; This is like the java expression:
;
;   StringBuffer x = new StringBuffer();
;
; Make a new StringBuffer object and leave a reference to it
; on the stack:
new java/lang/StringBuffer
; [ Stack now contains: objectref ]
; Duplicate the object reference:
dup
; [ Stack now contains: objectref objectref ]
; Invoke the object's initializer:
invokespecial java/lang/StringBuffer/&lt;init&gt;()V
; [ Stack now contains: objectref ]
; Store the objectref in local variable 1.
astore_1
; [ Stack is now empty. ]
</pre></dd><dt>See also</dt><dd><a href="ref-dup2.html">dup2</a> <a href="ref-.html"></a> <a href="ref-dup_x1.html">dup_x1</a> <a href="ref-.html"></a> <a href="ref-dup2_x1.html">dup2_x1</a> <a href="ref-.html"></a> <a href="ref-dup2_x2.html">dup2_x2</a> </dd><dt>Stack</dt><dd><table xmlns="">
<tr>
<td>
<b>Before </b>
</td>
<td><b>After</b></td></tr>
<tr>
<td>item</td>
<td>item</td></tr>
<tr>
<td>...</td>
<td>item</td></tr>
<tr>
<td></td>
<td>...</td></tr>
</table></dd><dt>Bytecode</dt><dd><table xmlns="">
<tr>
<td>
<b> Type </b>
</td>
<td><b>Description</b></td></tr>
<tr>
<td>
u1 
</td>
<td>dup
opcode = 0x59 (89)
</td></tr>
</table></dd></dl></body></html>